package File;

import java.io.IOException;
import java.nio.file.Path;
import java.nio.file.Paths;

public class AddAndSubtractPaths {
    static Path base = Paths.get("..", "..", "..").toAbsolutePath().normalize();
    static void show(int id, Path result) {
        if (result.isAbsolute()) {
            System.out.println("(" + id + ")r " + base.relativize(result));
        }else
            System.out.println("(" + id + ") " + result);
        try {
            System.out.println("RealPath: " + result.toRealPath());
        } catch(IOException e) {
            System.out.println(e);
        }
    }
    public static void main(String[] args) {
        System.out.println(base);
        Path path = Paths.get("src/main/java/functional_programming/AddAndSubtractPaths.java").toAbsolutePath();
        System.out.println(path);
        show(1,path);
        Path con = path.getParent().getParent().resolve("strings").resolve("..").resolve(path.getParent().getFileName());
        show(2, con);
        show(3,con.normalize());
        Path p2 = Paths.get("..", "..");
        show(4, p2);
        show(4, p2.normalize());



    }
}
